<?php
session_start();

//注销登录
if($_GET['action'] == "logout"){
    unset($_SESSION['userid']);
    unset($_SESSION['username']);
    //echo '注销登录成功！点击此处 <a href="index.php">登录</a>';
    header('location:index.php');
    exit;
}

//登录
if($_SERVER['REQUEST_METHOD'] != "POST") {
//if(!isset($_POST['submit'])){
    exit('非法访问!');
}
$username = htmlspecialchars($_POST['username']);
$password = MD5($_POST['password']);

//包含数据库连接文件
include('system/db/conn.php');
//检测用户名及密码是否正确
$check_query = mysql_query("select id,supplier_id from do_supplier_account where account_name='$username' and account_password='$password' 
limit 1");
if($result = mysql_fetch_array($check_query)){
    //登录成功
    $_SESSION['username'] = $username;
    $_SESSION['userid'] = $result['id'];
    $_SESSION['logintype'] = "supplierlog"; 
     $_SESSION['supplierid'] = $result['supplier_id'];
     if(isset($_SESSION['yesorno1'])){
       unset($_SESSION['yesorno1']);
    }
    header('location:shop-xx.php');
    //echo $username,' 欢迎你！进入 <a href="my.php">用户中心</a><br />';
    //echo '点击此处 <a href="login.php?action=logout">注销</a> 登录！<br />';
    exit;
} else {
    //exit('登录失败！点击此处 <a href="javascript:history.back(-1);">返回</a> 重试');
     $_SESSION['yesorno1']="yes";
     header('location:index.php');
}
?>